<?php
defined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_app_class('admin','admin',0);

class manage extends admin {
	private $db;
	public $site;
	function __construct(){
		parent::__construct();
		pc_base::load_app_func('global');
		$this->db = pc_base::load_model('motoreg_model');//加载model
		$this->siteid = get_siteid();//获取当前站点
	}
	
	/**
	 *模特报名信息列表
	 */
	public function init() {
		$where = "";
		$where .= "status = 0 and site =".$this->siteid;
		$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
		$motoinfo = $this->db->listinfo($where,'id DESC',$page,10);
		$pages = $this->db->pages;
		pc_base::load_sys_class('format', '', 0);
		include $this->admin_tpl('motoreg_list');
	}
	
	/**
	 *模特报名信息详情
	 */
	public function detail() {
		$id = isset($_GET['id']) ? $_GET['id'] : showmessage(L('message not exists'), HTTP_REFERER);
		$info = $this->db->get_one(array('id'=>$id));
		$show_header = false;
		pc_base::load_sys_class('format', '', 0);
		pc_base::load_sys_class('form', '', 0);
		include $this->admin_tpl('motoreg_detail');
	}
	
	/**
	 *模特报名信息删除、批量删除
	 */
	public function moto_del() {
		if (!isset($_REQUEST['id']) || empty($_REQUEST['id'])) {
			showmessage(L('illegal_action'), HTTP_REFERER);
		}
		$id = $_REQUEST['id'];
		if (is_array($id)) {
			foreach ($id as $k=>$v){
				if (intval($v)) {
					$id[$k] = intval($v);
				} else {
					unset($id[$k]);
				}
			}
			$id = implode('\',\'', $id);
		}
		$result = $this->db->update(array('status'=>'1'),"id in ('$id')");
		if($result){
			showmessage(L('del_success'),HTTP_REFERER);
		}else {
			showmessage(L('del_error'),HTTP_REFERER);
		}
	}
}